local audio = require("framework.audio")
local audioPath = require("app.res.audio.config")
local M = class("startScene", function()
    return display.newScene("startScene")
end)

function M:ctor()
    audio.playMusic(audioPath.beginBg)
    cc.ui.UILabel.new({
            UILabelType = 2, text = "Hello, World", size = 64})
        :align(display.CENTER, display.cx, display.cy)
        :addTo(self)

    local bg = display.newSprite("images/bg_0.png")
    	:align(display.CENTER, display.cx, display.cy)
        :addTo(self)

    local title = display.newSprite("#begin_07.png")
    	:align(display.CENTER, display.cx, display.cy)
        :addTo(self)

   	local title_1 = display.newSprite("#begin_06.png")
   		:addTo(title)
   		:align(display.BOTTOM_CENTER, title:getContentSize().width*0.52, title:getContentSize().height*0.97)
   	local title_2 = display.newSprite("#begin_05.png")
   		:addTo(title)
   		:align(display.BOTTOM_LEFT, title:getContentSize().width*0.52+title_1:getContentSize().width*0.5, title:getContentSize().height*0.97)

   	cc.ui.UIPushButton.new{normal = "#begin_01.png",pressed = "#begin_02.png"}
		:align(display.RIGHT_BOTTOM, display.width, display.bottom)
		:addTo(self, 0)
    :onButtonPressed(function (  )
        audio.playSound(audioPath.button)
    end)
		:onButtonClicked(handler(self, self.onStart))

    -- audio.preloadMusic(audioPath.gameBg)
end

function M:onStart(event)
	require("app.MyApp").new():enterScene("gameScene",nil,"Fade",0.4)
end

function M:onEnter()
end

function M:onExit()
end

return M
